package com.intranet.fund.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.intranet.fund.dao.ApplicantDao;
import com.intranet.fund.domain.Applicant;
import com.water.dao.Page;

@Service
public class ApplicantService {

	@Autowired
	private ApplicantDao applicantDao;

	public Page getAllApplicant(int pageNo, int pageSize, String param) {
		return applicantDao.queryApplicantList(pageNo, pageSize, param);
	}

	public String saveApplicant(Applicant applicant) {
		String msg = "";
		try {
			applicantDao.save(applicant);
			msg = "Y";
		} catch (RuntimeException e) {
			msg = e.toString();
		}
		return msg;
	}

	public String updateApplicant(Applicant applicant) {
		String msg = "";
		try {
			applicantDao.update(applicant);
			msg = "Y";
		} catch (RuntimeException e) {
			msg = e.toString();
		}
		return msg;
	}

	public String deleteApplicant(Applicant applicant) {
		String msg = "";
		try {
			applicantDao.remove(applicant);
			msg = "Y";
		} catch (RuntimeException e) {
			msg = "N";
		}
		return msg;
	}

	public Applicant getApplicantById(Integer id) {
		return applicantDao.get(id);
	}
}
